<!-- Modal -->
<div class="modal fade " id="addDimensionQuotaTypeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">维度新增</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal">
                <div class="box-body">
                    <div class="form-group">
                        <label for="inputEmail5" class="col-sm-2 control-label">模板名称</label>
                        <div class="col-sm-7">
                            <input id="addDimensionQuotaTypeModal_versionName" type="text" class="form-control" readonly>
                            <input id="addDimensionQuotaTypeModal_versionId" type="hidden" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">维度名称</label>
                        <div class="col-sm-7">
                            <input id="dimensionQuotaTypeName" type="text" class="form-control">
                            <input id="dimensionId" type="hidden">
                        </div>
                    </div>
                    <div class="form-group" id="weightDiv">
                        <label for="inputEmail3" class="col-sm-2 control-label">维度权重</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="dimensionStyleValue">
                        </div>
                    </div>
                    <div class="form-group" id="weightDiv1">
                        <label class="col-sm-2 control-label" for="produ4ctTypeLabel">子权重类型</label>
                        <div class="col-sm-7">
                            <select id="dimensionQuotaTypeStyle" name="dimensionQuotaTypeStyle" class="form-control">
                                <option value="1">单独权重</option>
                                <option value="2">并集权重</option>
                            </select>
                        </div>
                    </div>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary pull-right" onclick="saveDimensionQuotaType()">保存</button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>

<script>

    function dimensionInit() {
        var modelName = $("#versionIdSelect").find("option:selected").text();
        $("#addDimensionQuotaTypeModal_versionName").val(modelName);
        $("#addDimensionQuotaTypeModal_versionId").val($("#versionIdSelect").val());
        $("#dimensionId").val("");
        $("#dimensionParentName").val("");
        $("#dimensionQuotaTypeId").val();
        $("#dimensionQuotaTypeName").val("");
        $("#dimensionStyleValue").val("");
    }

    function dimensionSetValue(row) {
        $("#dimensionId").val(row.id);
        $("#dimensionQuotaTypeName").val(row.quotaTypeName);
        $("#versionId").val(row.versionId);
        $("#dimensionStyleValue").val(row.styleValue);
        $("#dimensionQuotaTypeStyle").val(row.quotaTypeStyle);
    }

    function quotaTypeChange() {
        var type = $("#quotaTypeSelect").val();
        if ("1" == type) {
            $("#weightDiv").css("display", "block");
            $("#negativeDiv").css("display", "none");
        } else if ("2" == type) {
            $("#weightDiv").css("display", "none");
            $("#negativeDiv").css("display", "block");
        }
    }

    function saveDimensionQuotaType() {
        var data = {
            versionId: $("#addDimensionQuotaTypeModal_versionId").val(),
            id: $("#dimensionId").val(),
            quotaTypeName: $("#dimensionQuotaTypeName").val(),
            styleValue: $("#dimensionStyleValue").val(),
            quotaTypeStyle: $("#dimensionQuotaTypeStyle").val()
        };
        var url = "/evaluationquota/add";
        if (data.id != "" && data.id != undefined) {
            url = "/evaluationquota/modify";
        }
        postReq(url, data, function (result) {
            if (result.success) {
                toastr['success']('操作成功', '提示');
                refreshTable('table1');
                $("#addDimensionQuotaTypeModal").modal("hide");
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }
</script>
